﻿#region

using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

#endregion

namespace CuongHanh.Models
{
    [Table("tbl_Product")]
    public class Product : BaseClass
    {
        public Product()
        {
        }

        public Product(int branchId)
        {
            BranchId = branchId;
        }

        public Product(Product model)
        {
            BranchId = model.BranchId;
            CategoryId = model.CategoryId;
            SubCategoryId = model.SubCategoryId;
            Code = model.Code;
            NameVi = model.NameVi;
            NameEn = model.NameEn;
            NameZh = model.NameZh;
            BestSaler = model.BestSaler;
            IsShowIndex = model.IsShowIndex;
            New = model.New;
            Price = model.Price;
            SaleOff = model.SaleOff;
            CreateDate = DateTime.Now;
            Invisible = model.Invisible;
            Inactive = false;
            LastModified = DateTime.Now;
        }

        [Required]
        public int BranchId { get; set; }

        [Required]
        [Display(Name = "Danh Mục")]
        public int CategoryId { get; set; }

        [Required]
        [Display(Name = "Danh Mục Con")]
        public int SubCategoryId { get; set; }

        [Required]
        [Display(Name = "Mã")]
        public string Code { get; set; }

        [Required]
        [Display(Name = "Tên T.Việt")]
        public string NameVi { get; set; }

        [Display(Name = "Tên T.Anh")]
        public string NameEn { get; set; }

        [Display(Name = "Tên T.Hoa")]
        public string NameZh { get; set; }

        public string Image { get; set; }

        public string Article { get; set; }

        [Display(Name = "H.Thị Trên T.Chủ")]
        public bool IsShowIndex { get; set; }

        [Display(Name = "S.Phẩm Bán Chạy")]
        public bool BestSaler { get; set; }

        [Display(Name = "S.Phẩm Mới")]
        public bool New { get; set; }

        [Display(Name = "Giá")]
        public long Price { get; set; }

        [Display(Name = "Giá Khuyến Mãi")]
        public long SaleOff { get; set; }

        [Display(Name = "Ngày Tạo")]
        public DateTime CreateDate { get; set; }

        [Display(Name = "Ẩn")]
        public bool Invisible { get; set; }

        public void UpdateInfoFrom(Product model)
        {
            BranchId = model.BranchId;
            CategoryId = model.CategoryId;
            SubCategoryId = model.SubCategoryId;
            Code = model.Code;
            NameVi = model.NameVi;
            NameEn = model.NameEn;
            NameZh = model.NameZh;
            BestSaler = model.BestSaler;
            IsShowIndex = model.IsShowIndex;
            New = model.New;
            Price = model.Price;
            SaleOff = model.SaleOff;
            Invisible = model.Invisible;
            LastModified = DateTime.Now;
        }
    }
}
